import format from '@dfeidao/atom-mobile/dt/format';
import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import get from '@dfeidao/atom-mobile/local/get';
import nodejs from '@dfeidao/atom-mobile/msg/nodejs';
import render from '@dfeidao/atom-mobile/render/render';

// 函数在选取的日期或时间调用。它以javascript日期对象的形式返回日期或时间。
export default async function a005(fd: IFeidaoAiMobile, e: Date) {
	const user = await get(fd, 'user') as {
		params: {
			teacher_name: string;
			productid: string;
			teacher_no: string;
		}
	};
	const start_time = new Date(e.toLocaleDateString()).getTime();
	const date_time = await format(start_time, 0);

	const end_time = start_time + 86399999;

	const d = await nodejs('app-after-class-review/s001', {
		filter: {
			teacher_no: user.params.teacher_no,// teacher_no JS0004
			start_time,
			end_time,
			productid: user.params.productid
		}
	}) as {
		class_record: Array<{}>;
		teacher: Array<{}>
	};

	const isshow = false;
	render(fd, {
		d: d.class_record,
		isDateTimePickerVisible: isshow,
		time: date_time
	});
}
